package com.demo.rocketmq.consumer;

import com.demo.rocketmq.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQReplyListener;
import org.springframework.stereotype.Component;

/**
 * 请求/应答 消费端
 * 生产者发送Request消息使用SendAndReceive方法，消费者必须做ack通知生产者已收到消息，否则生产者一直等到消费者ack直到timeout
 * @author K
 */
@Slf4j
@Component
@RocketMQMessageListener(topic = "test-topic-3", consumerGroup = "test_topic_3_consumer_group")
public class TestTopic3RocketMqConsumer implements RocketMQReplyListener<String, User> {

    @Override
    public User onMessage(String message) {
        log.info("received test-topic-3 message: {}", message);
        User user = new User();
        user.setUserName(message);
        return user;
    }
}
